<include file="Public:header" />
<style type="text/css">
.call-records {
}
.current-bg {
	background-color: #fbffe4
}

table tr:nth-child(odd){background:#F4F4F4;}
/*table td:nth-child(even){color:#C00;}*/

</style>
<script type="text/javascript" src="__PUBLIC__/Js/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript" src="/Public/Js/progressbar/js/jquery.tips.js"></script>
<link rel="stylesheet" href="/Public/Js/progressbar/css/progressbar-style.css" />

<div class="subnav">
  <div class="explain-col" style="position: relative; ">
    <form name="searchForm" id="searchForm" method="GET" action="" >
      搜索：
      <input type="text" name="keyword" id="keyword" size="30" placeholder="请输入关键词"  value="{$Think.get.keyword}" class="input-text"  style="height:20px; width:120px; color:#999" />
      	<select name="province" id="province"  style="width:120px;" onchange="searchForm.submit()" >
	      <option value="0">请选择所属省份</option>
	        <volist name=":provinceList()" id="vo">
	          <option value="{$vo.id}" <eq name="Think.get.province" value="$vo.id"> selected="" </eq> >{$vo.name}</option>
	        </volist>
	    </select>

      <select name="visa_type" id="visa_type" onchange="searchForm.submit()" >
      	<option value="0">请选择签约类型</option>
        <volist name=":signArr('')" id="vo">
          <option value="{$vo.id}" <eq name="Think.get.visa_type" value="$vo.id"> selected="" </eq> >{$vo.name}</option>
        </volist>
      </select>
      <select name="process" id="process" onchange="searchForm.submit()" >
      	<option value="0">请选择处理类型</option>
        <volist name=":processArr('')" id="vo">
          <option value="{$vo.id}" <eq name="Think.get.process" value="$vo.id"> selected="" </eq> >{$vo.name}</option>
        </volist>
      </select>

      <select name="university_one" id="university_one" onchange="searchForm.submit()" >
      	<option value="0">请选择大学1</option>
        <volist name=":daxueArr('')" id="vo">
          <option value="{$vo.id}" <eq name="Think.get.university_one" value="$vo.id"> selected="" </eq> >{$vo.name}</option>
        </volist>
      </select>
      <select name="lianxiren" id="lianxiren" onchange="searchForm.submit()" >
      	<option value="0">请选择顾问老师</option>
        <volist name=":guwenArr('')" id="vo">
          <option value="{$vo.id}" <eq name="Think.get.lianxiren" value="$vo.id"> selected="" </eq> >{$vo.name}</option>
        </volist>
      </select>
       <select name="source" id="source" onchange="searchForm.submit()" >
      	<option value="0">请选择学生来源</option>
        <volist name=":laiyuanArr('')" id="vo">
          <option value="{$vo.id}" <eq name="Think.get.source" value="$vo.id"> selected="" </eq> >{$vo.name}</option>
        </volist>
      </select>
      <select name="apply_time" id="apply_time" onchange="searchForm.submit()" >
      	<option value="0">请选择申请时间</option>
        <volist name=":applyTimeArr('')" id="vo">
          <option value="{$vo.id}" <eq name="Think.get.apply_time" value="$vo.id"> selected="" </eq> >{$vo.name}</option>
        </volist>
      </select>

	  签约时间：
      <input type="text" name="start_date" id="start_date" size="30" placeholder="开始时间"  value="{$Think.get.start_date}" class="input-text Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" style="height:20px; width:120px; color:#999" />-
      <input type="text" name="end_date" id="end_date" size="30" placeholder="结束时间"  value="{$Think.get.end_date}" class="input-text Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" style="height:20px; width:120px; color:#999" />

      <input type="submit" value=" 搜索 " class="button" id="searchButton" />
    </form>
    <div class="content-menu" style="position: absolute; right: 30px;top: 5px;"> <a href="javascript:openWinBox('__CONTROLLER__/add','添加新客户',850);" class="add fb"><em>添加新客户</em></a> </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form name="myform" id="myform" action="" method="GET">
    <div class="table-list">
      <table width="100%" cellspacing="0" style="min-width:900px;">
        <thead>
          <tr>
            <th align="center" width="40" >选择</th>
            <th align="left" width="120">录入时间</th>
            <th align="left" width="60">所属顾问</th>
            <th align="left" width="60">咨询方式</th>
            <th align="left" width="60">意向级别</th>
            <th align="left" width="60">详细级别</th>
            <th align="left" width="80">学员名称</th>
            <th align="left" width="80">所在地</th>
            <th align="left" width="120">课程项目</th>
            <th align="left" width="120">详细课程</th>
            <th align="left" width="100" >联系电话</th>
            <th align="left" width="120">上次跟进</th>
            <th align="left" width="60">剩余天数</th>
            <th align="left" width="120">电话内容</th>
            <th align="left" width="120">下次跟进</th>
            <th align="center" width="60">跟进次数</th>
            <!-- <th align="center"  width="60">创建人</th> -->
            <th align="center" width="220">操作</th>
          </tr>
        </thead>
        <tbody  id="list">
          <volist name="list" id="vo">
            <tr id="list-{$vo.id}" value="{$vo.id}" class="{$vo.class}">
              <td align="center"><input type="checkbox" name="idArr[]" value="{$vo.id}"></td>
              <td align="left">{$vo.time_sign|date='Y/m/d',###}</td>
              <td align="left" ><a href="javascript:void(0)" onclick="selectMode({$vo.id});" >{$vo.name}</a></td>
              <td align="left" >{$vo.qq}</td>
              <td align="left" >{$vo.phone}</td>
              <td align="left">{$vo.xueli|getClassifyInfo='name'}</td>
              <td align="left">{$vo.province|getAreaInfo='name'}-{$vo.city|getAreaInfo='name'}-{$vo.area|getAreaInfo='name'}</td>
              <td align="left">{$vo.visa_type|getClassifyInfo='name'}</td>
              <td align="left">{$vo.process|processArr2}</td>
              <td align="left">{$vo.university_one|daxueArr='name'}/{$vo.major_one}</td>
              <td align="left">{$vo.university_two|daxueArr='name'}/{$vo.major_two}</td>
              <td align="left">{$vo.university_three|daxueArr='name'}/{$vo.major_three}</td>
              <td align="left">{$vo.apply_time|getClassifyInfo='name'}</td>
              <td align="left">{$vo.source|getClassifyInfo='name'}</td>
              <td align="left">{$vo.contract_type|getClassifyInfo='name'}</td>
              <td align="center">{$vo['sign_status']==1?'已签':'在谈'}</td>
              <!-- <td align="center">{$vo.update_time|tranTime}</td> -->
              <!-- <td align="center">{$vo.creater}</td> -->
              <td align="center" class="detail">

              <a href="javascript:openWinBox('__CONTROLLER__/add/id/{$vo.id}','客户信息')" >【修改】</a>
              <a href="javascript:openWinBox('__CONTROLLER__/addContent/id/{$vo.id}','追加跟进内容')" >【追加跟进内容】</a>
              </td>
            </tr>
          </volist>
        </tbody>
      </table>
    </div>
    <div class="btn" style="min-width:830px;" >
      <div id="pages">{$page}</div>
      <input name="submit" id="checkall" type="button" class="button" value="全选/反选">
      <eq name="Think.session.user_id" value="1">
      	<input name="submit" type="button" class="button" value="删除所选"  onclick="return deleteConfirm();">
      	<!-- <input name="submit" type="button" class="button" value="转交客户" id="transfer"> -->
      	<input name="submit" type="button" class="button" value="导出客户资料"  onclick="return exportExcel();">
      </eq>
    </div>
  </form>
</div>
</body>
</html>

<script type="text/javascript">
$(function(){


	$('#myform').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		var len = $("input[name='spaceid[]']:checked").length;
		if(len < 1){
			msg('请先选择删除项！','warning',3);
			return false;
		}
	}
	var origin = $.artDialog.open.origin;
	function complete(data){
		msg(data.info,data.data);
		if(data.status) setTimeout(function(){origin.location.reload();},1500);
	}

	//全反选
	$("#checkall").click(function(){
		$("input[name=idArr[]]").each(function(){
			if(this.checked == false)
				this.checked = true;
			else
				  this.checked = false;
		});
	});

})


function checkedId(){
	var id = new Array();
	var i = 0;
	$("input[name='idArr[]']").each(function() { //由于复选框一般选中的是多个,所以可以循环输出
		if(this.checked == true){
			id[i] = $(this).val();
			i++;
			$('#list-'+$(this).val()).remove();
		}
	});
	return id;
}

function deleteConfirm(){
	window.top.art.dialog({
		content: '确定删除所选数据？',
		ok: function () {
			del();
			return true;
		},
		cancelVal: '取消',
		cancel: true
	});
}

function del(){
	var idArr = Array();
	var i = 0;
	var id;
	$("input[name='idArr[]']").each(function(){
		if(this.checked == true){
			idArr[i] = $(this).val();
			i++;
		}
	});
	jQuery.post('__CONTROLLER__/del',encodeURI('id='+idArr),success,'json');
	function success(data){
		if(data.status==1){
			window.top.art.dialog({id:'TNCICC',content: data.info,time: 2,icon:'succeed'});
			setTimeout(function(){window.location.reload();closeWin(1500);},2000);
		}else{
			window.top.art.dialog({id:'TNCICC',content: data.info,time: 2,icon:'warning'});
		}

	}
}

function checkForm(){
	var keyword = $("input[name='keyword']").val();
	keyword = encodeURI(keyword).replace(/%/g,'.s.');
	$("input[name='keyword']").val(keyword);
	return true;
}

function exportExcel(){
	$("#searchForm").attr('action','__CONTROLLER__/exportExcel');
	$("#searchForm").submit();
	return false;
}


function selectMode(clientId){
	openWinBox('__CONTROLLER__/detail/id/'+clientId,'查看详细信息');
}

function loadCallRecord(id){
		if($('#content-'+id).attr('id')!=undefined){
			$('.call-records').hide();
			$('.current-bg').removeClass('current-bg');
			$('#content-'+id).show();

			$('#content-'+id).addClass('current-bg');
			$('#list-'+id).addClass('current-bg');
		}else{
			getCallRecordList(id);
		}
		return true;
}

function getCallRecordList(id){
	$.ajax({
			type:'GET',
			url:"__CONTROLLER__/getCallRecord",
			dataType:'text',
			data:encodeURI('id='+id),
			beforeSend:function(){
				$('#list-'+id).after('<tr class="jiazai"><td align="center" colspan="10" style="color:#F00" >正在加载。。。</td></tr>');
				$('.call-records').hide();
				$('.current-bg').removeClass('current-bg');
			},
			success:function(data){
				var data = eval('('+data+')');
				$('#list-'+id).after(data.data);
		  		$('#list-'+id).addClass('current-bg');
				$('#content-'+id).addClass('current-bg');
			},
			complete: function(XMLHttpRequest, textStatus){
				$('.jiazai').remove();
			},
			error: function(){}
		});
		return true;
}


//修改文章分类
$("#transfer").click(function(){
	var idArr = Array();
	var i = 0;
	var id;
	$("input[name='idArr[]']").each(function(){
		if(this.checked == true){
			idArr[i] = $(this).val();
			i++;
		}
	});
	if(idArr==''){
		msg('请选择要转交的客户！','warning',2);
		return false;
	}
	openWinBox('__CONTROLLER__/transfer/idArr/'+idArr,'更改所属分类',400,150);
})
</script>

<script type="text/javascript">
$(document).ready(function(){
	$(".progress_bar").each(function(index, el) {
		var percent = $(this).attr('title');
		$(this).animate({width:percent},1000);
		//$(this).tipsy({gravity:'s',fade:true});
	});

});
</script>